package ipgather.core.host.thread;

public class SyncStackHost {

	private int index =0;
	private int len = 20;
	private String[] hosts = new String[len];
	

	public synchronized void push(final String host){
		while(index==len){
			try {
				this.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		this.notify();
		hosts[index] = host;
		index++;
	}
	
	public synchronized String pop(){
		while(0==index){
			try {
				this.wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		this.notify();
		index--;
		return hosts[index];
	}
}
